# -*- coding: utf-8 -*-
import os
import sys
import time
import glob
import codecs
import ez_setup
ez_setup.use_setuptools()
from setuptools import setup, find_packages

version = '0.1'

folder = os.path.dirname(os.path.abspath(__file__))

flag = '--include-jars'
include_jars = ( flag in sys.argv )
if include_jars:
    sys.argv.remove(flag)

if not include_jars and 'bdist_egg' in sys.argv:
    print >> sys.stderr, 'bdist_egg is no available, can not embed jar in .egg for license reasons...'
    sys.exit(1)

if not include_jars and 'sdist' in sys.argv:
    libs = os.path.join(folder, 'selenose', 'libs')
    if glob.glob(os.path.join(libs, '*.jar')):
        print >> sys.stderr, 'Please delete all jars in %s before running sdist...' % libs
        sys.exit(1) 
else:
    from selenose.libs import download
    download()

if not os.path.exists(os.path.join(folder, 'PKG-INFO')):
    info = {
        'version': repr(version),
        'timestamp': int(time.time()),
    }
    fd = codecs.open(os.path.join(folder, 'selenose', '__version__.py'), 'w', 'utf-8')
    fd.write("""#-*- coding: utf-8 -*-
version   = %(version)s
timestamp = %(timestamp)s
""" % info)

install_requires = [
    'nose >= 0.11.4',
    'nosango >= 0.1.0',
    'selenium >= 2.0a5',
    'PyYAML >= 3.09',
]
if sys.platform == 'win32':
    install_requires.append('pywin32 >= 214')

setup(
    name = 'selenose',
    version = version,
    description = "Django's Selenium test plugin for Nose",
    long_description = 'A plugin for nose/nosetests to test Django applications with Selenium.',
    url = 'http://code.google.com/p/selenose/',
    download_url = 'http://pypi.python.org/pypi/selenose/',
    license = 'GNU Library or Lesser General Public License (LGPL)',
    author = 'ShiningPanda',
    author_email = 'developers@shiningpanda.com',
    packages = find_packages(),
    include_package_data = True,
    zip_safe = False,
    classifiers = [
        'Development Status :: 5 - Production/Stable',
        'Environment :: Plugins',
        'Framework :: Django',
        'Intended Audience :: Developers',
        'Operating System :: OS Independent',
        'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
        'Natural Language :: English',
        'Programming Language :: Python',
        'Topic :: Software Development :: Testing',
        ],
    install_requires = install_requires,
    setup_requires = [
        'collective.dist>=0.2.5',
    ],
    dependency_links = [
        'https://dev.shiningpanda.com/pypi/simple/nosango/'                  
    ],
    entry_points = {
        'nose.plugins.0.10': [
            'selenose = selenose.plugin:Selenose' ,
        ],
        'console_scripts': [
            'selenose = selenose.run:run',
        ],
    },
    test_suite = 'nose.collector',
)
